Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flaky exit handler test #1049

Merged
merged 1 commit into from
Aug 30, 2022
Merged

fix: flaky exit handler test #1049

merged 1 commit into from
Aug 30, 2022

Conversation

dbanck
Copy link
Member

@dbanck dbanck commented Aug 25, 2022

This PR fixes the flaky exit handler test. The sleep makes sure that we account for the asynchronous nature of LS notifications.

I think using time.Sleep isn't the best, but a very pragmatic solution here.

Before

$ go test -timeout 30s -run '^TestExit$' github.com/hashicorp/terraform-ls/internal/langserver/handlers -count=1000
--- FAIL: TestExit (0.00s)
    exit_test.go:20: Expected service stop function to be called
--- FAIL: TestExit (0.00s)
    exit_test.go:20: Expected service stop function to be called
FAIL
FAIL    github.com/hashicorp/terraform-ls/internal/langserver/handlers  1.807s
FAIL

After

$ go test -timeout 30s -run '^TestExit$' github.com/hashicorp/terraform-ls/internal/langserver/handlers -count=1000
ok      github.com/hashicorp/terraform-ls/internal/langserver/handlers  13.512s

Closes #445

This sleep makes sure that we account for the asynchronous
nature of LS notifications.
@dbanck dbanck added the bug Something isn't working label Aug 25, 2022
@dbanck dbanck self-assigned this Aug 25, 2022
@dbanck dbanck requested a review from a team as a code owner August 25, 2022 16:30
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this is pragmatic. I assume that we'd have to rework the E2E test framework built on top of jrpc2 for any hope of a better solution.

There is https://pkg.go.dev/github.com/creachadair/jrpc2/server#NewLocal which we could consider, but ironically the exit handler was one of the few reasons I avoided it in the past as it made it hard to access the internal state to verify that a SIGTERM signal was received and method was called.

Maybe we can either avoid testing this particular handler, or use different approach. 🤷🏻

@dbanck dbanck merged commit 2738c6c into main Aug 30, 2022
@dbanck dbanck deleted the b-fix-exit-handler-test branch August 30, 2022 08:27
@radeksimko radeksimko added this to the v0.29.2 milestone Sep 12, 2022
@github-actions
Copy link

This functionality has been released in v0.29.2 of the language server.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Address flaky exit handler test
2 participants